import java.util.Arrays;

public class SolutionInterview16_3 {
    public double[] intersection(int[] start1, int[] end1, int[] start2, int[] end2) {
        if (start1[0]>end1[0]){
            int[] temp=start1;
            start1=end1;
            end1=temp;
        }
        if (start2[0]>end2[0]){
            int[] temp=start2;
            start2=end2;
            end2=temp;
        }
        double m=0.000000001;
        if (start1[0]==end1[0]){
            if (start1[1]>end1[1]){
                int[] temp=start1;
                start1=end1;
                end1=temp;
            }
            if (start2[0]==end2[0]){
                if (start2[1]>end2[1]){
                    int[] temp=start2;
                    start2=end2;
                    end2=temp;
                }
                if (start1[0]!=start2[0]){
                    return new double[0];
                }
                if (end1[1]<start2[1] || end2[1]<start1[1]){
                    return new double[0];
                }
                return new double[]{start1[0],Math.max(start1[1],start2[1])};
            }else{
                if (start2[0]>start1[0] || end2[0]<start1[0]){
                    return new double[0];
                }else{
                    double[] c=cal(start2,end2);
                    double y=start1[0]*c[0]+c[1];
                    if (y-start2[1]>-m && y-end2[1]<m && y-start1[1]>-m && y-end1[1]<m) {
                        return new double[]{start1[0],y};
                    }else{
                        return new double[0];
                    }
                }
            }
        }
        if (start2[0]==end2[0]){
            if (start2[1]>end2[1]){
                int[] temp=start2;
                start2=end2;
                end2=temp;
            }
            if (start1[0]>start2[0] || end1[0]<start2[0]){
                return new double[0];
            }else{
                double[] c=cal(start1,end1);
                double y=start2[0]*c[0]+c[1];
                if (y-start1[1]>-m && y-end1[1]<m && y-start2[1]>-m && y-end2[1]<m) {
                    return new double[]{start2[0],y};
                }else{
                    return new double[0];
                }
            }
        }
        if (end1[0]<start2[0] || end2[0]<start1[0]){
            return new double[0];
        }
        double[] c1=cal(start1,end1);
        double[] c2=cal(start2,end2);
        if (Math.abs(c1[0]-c2[0])<m){
            if (Math.abs(c1[1]-c2[1])<m){
                int x=Math.max(start1[0],start2[0]);
                return new double[]{x,c1[0]*x+c1[1]};
            }else{
                return new double[0];
            }
        }else{
            double x=(c2[1]-c1[1])/(c1[0]-c2[0]);
            if (x-Math.max(start1[0],start2[0])>-m && x-Math.min(end1[0],end2[0])<m){
                return new double[]{x,c1[0]*x+c1[1]};
            }else{
                return new double[0];
            }
        }
    }

    double[] cal(int[] start,int[] end){
        return new double[]{(1.0*end[1]-start[1])/(end[0]-start[0]),(1.0*end[0]*start[1]-end[1]*start[0])/(end[0]-start[0])};
    }

    public static void main(String[] args) {
        System.out.println(Arrays.toString(new SolutionInterview16_3().intersection(new int[]{0, -1}, new int[]{0, 1}, new int[]{-1, 1}, new int[]{1, 3})));
    }
}
